import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import AdminLayout from '../views/admin/AdminLayout.vue'
import AdminDashboard from '../views/admin/Dashboard.vue'
import AdminProducts from '../views/admin/Products.vue'
import AdminStores from '../views/admin/Stores.vue'
import AdminVideos from '../views/admin/Videos.vue'
import AdminMembers from '../views/admin/Members.vue'
import DashboardShopkeeper from '../views/admin/DashboardShopkeeper.vue'
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/admin',
    component: AdminLayout,
    meta: { requiresAuth: true },
    children: [
      { path: '', redirect: '/admin/dashboard', name: 'AdminRoot' },
      { path: 'dashboard', name: 'AdminDashboard', component: AdminDashboard },
      { path: 'dashboard-shopkeeper', name: 'DashboardShopkeeper', component: DashboardShopkeeper },
      { path: 'products', name: 'AdminProducts', component: AdminProducts },
      { path: 'products/:storeId', name: 'AdminProductsByStore', component: AdminProducts },
      { path: 'stores', name: 'AdminStores', component: AdminStores },
      { path: 'videos', name: 'AdminVideos', component: AdminVideos },
      { path: 'videos/:storeId', name: 'AdminVideosByStore', component: AdminVideos },
      { path: 'members', name: 'AdminMembers', component: AdminMembers },
    ]
  },
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
